package main

import "fmt"

//func removeDuplicates(nums []int) int {
//	if len(nums) <= 1 {
//		return 0
//	}
//	b := 1
//	for i := 1; i < len(nums); i++ {
//		if nums[i] != nums[i-1] {
//			b++
//		}
//
//	}
//	return b
//
//}

func removeDuplicates(nums []int) int {
	n := len(nums)
	if n == 0 {
		return 0
	}
	slow := 1
	for fast := 1; fast < n; fast++ {
		if nums[fast] != nums[fast-1] {
			nums[slow] = nums[fast]
			slow++
		}
	}
	return slow
}

func main() {
	fmt.Println("5:  ", removeDuplicates([]int{1, 2, 3, 4, 5}))
	fmt.Println("2:  ", removeDuplicates([]int{1, 1, 2}))
	fmt.Println("5:  ", removeDuplicates([]int{0, 0, 1, 1, 1, 2, 2, 3, 3, 4}))
	fmt.Println("0:  ", removeDuplicates([]int{}))
	//fmt.Println("5:  ",removeDuplicates([]int{1, 2, 3, 4, 5}))
}
